package com.sunni.dao_old.impl;

import com.sunni.dao_old.RoleDao;
import com.sunni.entity.Role;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.jdbc.core.BeanPropertyRowMapper;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.stereotype.Component;

import java.util.List;
@Component("roleDao")// 实例化 dao层
public class RoleDaoImpl implements RoleDao {

    @Autowired
    @Qualifier("jdbcTemplate") // 1.注入jdbcTemplate (applicationContext.xml中实例化的)
    private JdbcTemplate jdbcTemplate;

    @Override
    public List<Role> selectAll() {
        return jdbcTemplate.query("select * from sys_role",new BeanPropertyRowMapper<Role>(Role.class));
    }
}
